const HtmlWebpackPlugin = require("html-webpack-plugin");
const CopyWebpackPlugin = require("copy-webpack-plugin");
const path = require("path");

module.exports = {
  entry: {
    'index': path.resolve(__dirname, "src", "index.js"),
    'visualization': path.resolve(__dirname, "src", "visualization.js")
  },
  module: {
    rules: [
      {
        test: /\.css$/,
        use: ["style-loader", "css-loader"]
      },
      {
        test: /\.js$/,
        exclude: /node_modules/,
        use: ["babel-loader"]
      }
    ]
  },
  optimization: {
    splitChunks: { chunks: "all" }
  },
  plugins: [
    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, "src", "index.html")
    }),
    new HtmlWebpackPlugin({
      template: path.resolve(__dirname, "src", "visualization.html"),
      chunks: ['visualization'],
      filename: 'visualization.html'
    }),
    new CopyWebpackPlugin({
      patterns: [
        { from: 'public' }
      ]
    })
  ],
  resolve: {
    fallback: {
      fs: false
    }
  }
};
